package com.fzh.Zhanye.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import com.fzh.Zhanye.model.Resources;
import com.fzh.Zhanye.util.Constants;

public class ResourcesDao {

	public boolean save(Resources res) throws SQLException {
		Connection conn=null;
		PreparedStatement pstm=null;
		try {
			conn=DBConnection.getConnection();
			pstm=conn.prepareStatement(Constants.SQL_SAVE_RES);
			pstm.setString(1, res.getResId());
			pstm.setString(2, res.getResName());
			pstm.setString(3, res.getResPath());
			pstm.setString(4, res.getResType());
			pstm.setString(5, res.getCreator());
			pstm.setDate(6,new java.sql.Date(res.getCreateTime().getTime()) );
			pstm.setString(7, res.getUpdator());
			pstm.setDate(8, new java.sql.Date(res.getUpdateTime().getTime()));
			
			int count=pstm.executeUpdate();
			if(count>0){
				return true;
			}
		} 
		catch (Exception e) {
			e.printStackTrace();
		}
		finally {
			
			if(pstm!=null){
				pstm.close();
			}
			if(conn!=null){
				conn.close();
			}
		}
		return false;
	}	
}
	

